MongoToDebugConsole, the tool you will need to debug your REALbasic Project. It is a cross-platform REALbasic Plugin that funnels information from your project back to the C/C++ environment, where it is further processed.
Version 1.1.0 alpha, 3/22/2000
The first release contains the following Note: in WIN32 any nil will generate a unhandled exception and leads to a freeze. This is a bug in the initial version. This bug has been solved, so nil pointers will yield a nil (0) address and a locknumber (0).
Apparently the MacOS and MacsBug with "EBBE ON" did not catch such unhandled exceptions. Such an exception was the attempt to dereference a nil Handle. It has been corrected.
Version 1.0.0 alpha, 3/19/2000
® Alfred N. Van Hoek, Ph.D./Massachusetts General Hospital
vanhoek@receptor.mgh.harvard.edu
Without SoftWindows98 on a MacOS9 host I would not be able to test the WIN32 compatibility of the plugin.
What is so cool about remote debugging consoles?
Plugin writers for REALbasic, and other programmers who do most of the programming in C/C++ will use debugging tools to determine critical points in their developement of a program, plugin or code, and many approaches and resources are out there. One of the best ways to debug that also allow you to determine where the freeze occurs is by remote debugging. Not everybody has such resources available and other means are investigated that should meet a certain purpose. We've got MacsBug, we've also got a debugging feature built in REALbasic IDE, but we also have experiences that when a project runs perfectly in the IDE, that that not necessarily means it will compile, or will not crash after a built. If MacsBug is installed, the crash will throw us into something we do not understand, or you could have built in your project debug strings that will bring you into MacsBug. What you actually want is that the program keeps running, while recording certain debugging messages. Nathan at Virtual1 has written CuisinArt that puts a lot of those debugging stuff into your project and messages will appear in a console. However, this console is part of your modified project. When your project crashes, the console crashes too. His approach though is similar to debugging strings send to a remote console in the C/C++ environment. And because "remote" consoles for debugging are for free, why not give REALbasic the ability to use a remote console.
About The REALbasic-Plugin MongoToDebugConsole
MongoToDebugConsole is a 68K, PPC and WIN32 compatible REALbasic plugin that provides REALbasic with a "MongoToDCon" Class. The purpose of this plugin is to give you access to information about all the REALbasic objects in your project. This information is send to a debugging console, which is not part of your project. The name Mongo has been used, because CuisinArt from Virtual1 lead me to write this plugin. The drawback of that program is that the console "Mongotrace" is part of the program you want to debug. Using independent consoles to which messages are send exceptions can be catched that remain after your project crashes.
MacOS: DCon -DEMO, System Based Extension Console
For the MacOS, the DCon-debugging console used to be available at http://www.cache-computing.com/ (see the separate information documents), but apparently cache-computing is out-of-business. Emails that I have send do not arrive, and using the provided phone-number yields a disconnecting message. The only way to obtain this Console is thus by distrubution through third parties. One possibility is to check your CodeWarrior Version 5 CD, if you have one, because you can find DCon-Demo on the CW-5 disk. The other possibility is to request people to send you the DEMO, ask through the lists for instance, some people of the RB-community should have CW5, or had it earlier downloaded from cach-computing. I believe that when someone sending this, it is better than when you would download it. Just a legal thing.
Win32: DebugView/EE, An Application Console
For the WIN32 platform you can download the DebugView/EE for Windows NT/9x Version 3.24, dbgv98 folder, by Mark Russinovich. It has lots of possibilities to dump, intervene etc., and to do remote debugging through the internet, that's cool! The address is: http://www.sysinternals.com
SoftWindows98: A Fairly Convenient Way to Debug your WIN32 Project
Apparently, SoftWindows98, v 5.0.9, runs pretty robust on a G3-MacOS9 machine. I have a 400 MHz, 128 MB G3 powerbook that gives a good performance for debugging purposes.
MongoToDebugConsole: the way it works.
Plugin: simple plugin which will register a class, called MongoToDconClass, that has properties, methods, and an event. To make it damn clear: if you do not like CuisinArt, no big deal! You do not need it; write your own debugging code in your project, it will work too.
Event
The event, CallBack, you could use for your own purpose. It does not send messages to the console though. To implement the event, you must subclass MongoToDconClass. So, in REALbasic you create a class and set its super to MongoToDconClass. In the events list you will see the Callback event. To use it, you must put some code inside it.
Sub Callback()
Msgbox "Mongo was here"
End Sub
To execute the code, you need to create an instance of your MongoToDconClass subclass, and call its Run method. This will end up with the Callback event being called and the REALbasic code you supplied for that event will be executed.
Sub Action()
Dim myDcon as myMongoToDconClass
myDcon = new MongoToDconClass
myDcon.run
End Sub
Stick the above in a pushbutton, and you ought to get a messagebox thrown up.
Properties
Properties of the MongoToDcon class are:
MongoToDcon.Str as String
MongoToDcon.Picture as Picture
MongoToDcon.Graphics as Graphics
MongoToDcon.Control as Control
MongoToDcon.Object as Object
MongoToDcon.Window as Window
MongoToDcon.FolderItem as FolderItem
MongoToDcon.DatabaseCursor as DatabaseCursor
MongoToDcon.Database as Database
MongoToDcon.Socket as Socket
#if targetMacOS
MongoToDcon.Movie as Movie
MongoToDcon.Sound as Sound
MongoToDcon.AppleEvent as AppleEvent
#endif
Once a property is assigned a message is generated to the console:
Do this:
dim mDcon as MongoToDcon
dim pic as picture
dim g as graphics
dim s as sound
dim m as movie
dim w as window
dim c as control
dim o as object
dim f as folderitem
dim dBase as database
dim dcurs as databasecursor
dim ae as appleEvent
dim
//Instantiate a sub class by
mDcon= new MongoToDcon
// assign properties that generates text in console, here some examples
mDcon.str = myString // or
mDcon.str = "Hello World" // "Hello World" will appear
mDcon.graphics = g // " graphics address(2ae46df) lockGraphics (4)
mDcon.window = w
mDcon.movie = nil // " movie address (0) lockMovie (0)
mDcon.object = o
mDcon.control = c
mDcon.sound = s
mDcon.folderitem = f
mDcon.database = dbase
mDcon.databaseCursor = dcurs
Note: in WIN32 any nil will generate a unhandled exception and leads to a freeze.
Some of these properties are obviously redundant, but useful if you want to discriminate between a Window, control, class or another object other then seeing object address...., object address..., object address... The same holds for the methods below.
Methods
(if you do not have or do not want to use remote consoles, but want to see addressing and locking numbers)
Methods:
MongoString(s as String) as string
MongoPicture(pic as Picture) as string
MongoGraphics(g as Graphics) as string
MongoControl(con as Control) as string
MongoFolderItem(f as FolderItem) as string
MongoSocket(s as Socket) as string
MongoDatabaseCursor(cur as DatabaseCursor) as string
MongoDatabase(db as Database) as string
MongoWindow(win as Window) as string
MongoObject(obj as Object) as string
#ifndef WIN32
MongoMovie(mov as Movie) as string
MongoSound(s as Sound) as string
MongoAppleEvent(a as AppleEvent) as string
#endif
These methods do the same thing as when using the property, i.e. sending debugging strings to the console, but they return also these strings to the RB-environment. If you do not want to use consoles, these strings can be used within the project. This means these strings will appear in the MongoTrace Console of Virtual1_CuisinArt project.
Here is an example to send strings to Dcon or dbgView, using Virtual1's MongoWIN where you need to define a property (global to the MongoWIN Window) like : mdcon as MongoToDcon
In the open event of MongoWIN do this:
Sub Open()
mdcon = new MongoToDcon
end Sub
In the already defined method do this to modify it:
Sub MongoTrace(Indenting as boolean, This as string)
dim myString as string
dim MongoDisk as FolderItem
dim MongoText as TextOutputStream
Me.hide //hide the cuisineArt_console
if Indenting then
Indent=Indent+" "
end if
//EditField1.SelText=Indent+This+chr(13) not necessary
//EditField1.SelStart=lenb(EditField1.Text) not necessary
mdcon.str = indent + this
if not Indenting then
Indent=midb(Indent,3)
end if
end Sub
Having this MongoToDCon class with properties, it allows for the following assignment myString = MongoToDcon.Str, or myPicture = MongoToDcon.Picture.
For what its worth you may need this feature to pass-on objects. Let me know if it would be useful, and if other features are required.
The internals of REALbasic: Addressing and lockNumbers, what it means and how you could use it to your advantage.
The address you will get for an object or instance of an object is given in a hexadecimal number. If it is nul it means no address. If it is very large, usually an 8 digit number, it also means a nil pointer, or a pointer waggling in the breeze. The lock-count-number also indicates that the pointer points to something or nothing. If it is nul it means that the pointer points to garbage, and RB will collect it as garbage. Sometimes you will notice a lock-count-number in the 7-hexadecimal digit range. This also means that the pointer points to garbage. If everything would be perfect, any valid pointer will point to an instance that would have a lock-number of 1 or 2. If you see 5 or 6, it would mean that 5, respectively, 6 pointers are pointing to the instance. This is the way REALbasic works; as long as the lock-number is 1 or higher it will not be garbage collected. An example of a locknumber of 5 is encountered for a listbox in a window. Why it should be 5 is related to internal structures within REALbasic. It is 5 under MacOS, but 6 under WIN32. Strings usually have a lock-number of 2 to 3, graphics 3, pictures 2, etc, Check them out. If for some reason the lock number of an instance is increasing, it probably is a sign of a memory leak.
Since James Milne came to RB, he had put into REALbasic a lot of debugging strings that appeared in the debugging console DCon. In time many of these strings have been removed, but if you start up REALbasic with Dcon enabled you will see "AppearancePak installed". It does not come from your debugging code. Also, if you have a placard in the window, additional messages can be observed. On the WIN32 platform you will notice other messages, such as NuList::Nulist for a listbox. Don't worry, it is because we are using alpha releases.